package org.tinygroup.sdpm.zhang.userController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.tinygroup.sdpm.common.web.BaseController;
import org.tinygroup.sdpm.zhang.dao.inter.pojo.Goods;
import org.tinygroup.sdpm.zhang.service.inter.GoodsServiceInter;

@RestController
@RequestMapping("goods")
public class GoodsController extends BaseController {
    @Autowired
    private GoodsServiceInter goodsServiceInter;

    @RequestMapping("good/{pk}")
    public Goods findGoodsById(@PathVariable String pk){
        return goodsServiceInter.getGoodsByKey(pk);
    }

    @RequestMapping("remove/{pk}")
    public void removeGoodById(@PathVariable String pk){
        goodsServiceInter.deleteGoodsByKey(pk);
    }

    @RequestMapping("addGoods")
    public void addGood(@RequestBody Goods goods){
        goodsServiceInter.addGoods(goods);
    }

    @RequestMapping("editGoods")
    public void editGoods(@RequestBody Goods goods){
        goodsServiceInter.editGoods(goods);
    }



}
